import { Project,Node } from "ts-morph";

// const project = new Project({
//   tsConfigFilePath: "tsconfig.json",
// });
const project=new Project();
project.addSourceFilesAtPaths("t.ts");
// project.createSourceFile("./file.ts","let v=\"hello\";");

const sourceFiles = project.getSourceFiles();

let sourceflie=sourceFiles[0]
let rootN=sourceflie.getFirstChild()
let x=1;
let y=(x=1);


function singlePrintAST(node:Node|undefined,i:number){
    if (node==undefined)
        return;
    console.log(' '.repeat(i)+node.getKindName())
    if (node.getChildren()==null)
        return;
    for(let c of node.getChildren()){
        singlePrintAST(c,i+1)
    }
}
singlePrintAST(rootN,0)



// sourceFiles.forEach((file) => {
//   console.log(file.getFilePath());
// });

// let file=sourceFiles[0].getDescendants();
// console.log(file)
// console.log(file.getChildren())

// const variables = sourceFiles.flatMap((sourceFile) => sourceFile.getVariableDeclarations());

// variables.forEach((variable) => {
//   console.log(variable.getName());
// });

// import { Project, SyntaxKind } from "ts-morph";

// const project = new Project();
// project.addSourceFilesAtPaths("path/to/your/files");

// const sourceFile = project.getSourceFileOrThrow("path/to/your/file.ts");
// const rootNode = sourceFile.getFirstChildByKind(SyntaxKind.SourceFile);

// // Get the first class declaration node
// const classDeclaration = rootNode.getFirstChildByKind(SyntaxKind.ClassDeclaration);

// // Get the name of the class
// const className = classDeclaration.getName();

// // Get all the properties of the class
// const properties = classDeclaration.getProperties();

// // Get all the methods of the class
// const methods = classDeclaration.getMethods();
